﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;
namespace Data
{
   public class TacGiaRepository
    {
       public static List<TacGiaDTO> GetTacGiacList()
       {           
           NhaSachEntities context = new NhaSachEntities();
           var q = from tg in context.TacGiaList
                   select new TacGiaDTO
                   {
                       MaTacGia=(int)tg.MaTacGia,
                       TenTacGia=tg.TenTacGia,
                       TinhTrang=(int)tg.TinhTrang
                   };
           return q.ToList();
       }
       public static TacGiaDTO GetTacGiaByMaTacGia(int maTacGia)
       {
           NhaSachEntities context = new NhaSachEntities();
           var q = (from tg in context.TacGiaList
                   where tg.MaTacGia == maTacGia
                   select new TacGiaDTO()
                   {
                       MaTacGia = (int)tg.MaTacGia,
                       TenTacGia = tg.TenTacGia,
                       TinhTrang = (int)tg.TinhTrang
                   }).FirstOrDefault();
           return q;
       }
    }
}
